const fs = require("fs");

const chat = require("./chat-server/model/chat"),
    room = require("./chat-server/model/room"),
    user = require("./chat-server/model/user");

function TESTaddUser(account, pwd, name, avatar) {
    user.add(account, pwd, name, avatar, data => {
        console.log(data);
    });
}

function TESTcreateRoom(name, creatorId) {
    room.create(name, creatorId, data => {
        console.log(data);
    });
}

function TESTaddMember(roomId, memberId) {
    room.addMember(roomId, memberId, data => {
        console.log(data);
    });
}

process.stdin.setEncoding("utf8");

process.stdout.write("Please choose a Test Model:\n");

const readlineSync = require("readline-sync");
let select = readlineSync.questionInt(
    "1. addUser   2. createRoom  3. addMember \n"
);

if (select === 1) {
    let account, pwd, name, avatar;
    account = readlineSync.question("Please input the account:\n");
    pwd = readlineSync.question("Please input the password:\n");
    name = readlineSync.question("Please input the nickname:\n");
    avatar = readlineSync.question("Please input the avatar:\n");
    TESTaddUser(account, pwd, name, avatar);
} else if (select === 2) {
    let name, creatorId;
    name = readlineSync.question("Please input the name of this room:\n");
    creatorId = readlineSync.question("Please input the creatorId:\n");
    TESTcreateRoom(name, creatorId);
} else if (select === 3) {
    let roomId, memberId;
    roomId = readlineSync.question("Please input the roomId:\n");
    memberId = readlineSync.question("Please input the memberId:\n");
    TESTaddMember(roomId, memberId);
}

// if (Number(chunk) === 1) {
//     process.stdout.write("Please input the account:\n");
//     let account = chunk
//     process.stdout.write("Please input the password:\n");
//     let pwd = chunk
//     process.stdout.write("Please input the nickname:\n");
//     let name = chunk
//     process.stdout.write("Please input the avatar:\n");
//     let avatar = chunk

//     console.log(account, pwd, name, avatar + "\n");
// }
